home *** CD-ROM | disk | FTP | other *** search
AMOS Source Code | 1992-02-26 | 3.1 KB | 96 lines |
- '
- ' Med with samples
- ' By Edmund Clay
- ' June 94
- '
- ' This cures the problem that all samples are looped after a med module
- ' has been loaded.
- ' This is an update to the program on AZ#2, which had a few bugs (not
- ' surprising given that what I am trying to do is Not Recommended,
- ' illegal and entirely immoral) If all goes well, this is the procedure I
- ' will use in GRAC, the graphic adventure creator which I am writing. It
- ' will support both Med and ST modules, with sound effects. Incidently,
- ' The ST play command from the CRAFT extension is the most reliable music
- ' system for Amospro, if you can live without med. It can suspend music
- ' on individual channels while a sample is playing and you can also set
- ' the starting pattern.
- '
- '----------------------------------------------------------------------
- '
- 'Needs a small, blank memory bank.
- '
- Reserve As Work 4,1024
- Fill Start(4) To Start(4)+Length(4),0
- '
- ' Load a med module...
- '
- Med Load Fsel$(""),6
- '
- ' Play until mouse
- '
- Print "Playing module, click mouse to stop."
- Med Play 6
- While Mouse Key=0 : Wend
- While Mouse Key<>0 : Wend
- '
- ' Stop the module
- '
- Med Stop
- Print "Click mouse to play sample."
- Do
- While Mouse Key=0 : Wend
- While Mouse Key<>0 : Wend
- '
- ' Play sample
- '
- SAM["%1000",1,10000,0]
- Loop
- '
- ' An interesting point is that this bug actually works to your advantage,
- ' because you can now choose whether to have individual samples looped or not,
- ' which AMOS doesn't normally allow.
- ' If you try to play samples at the same time as Med modules, you have no
- ' control over the frequency if med is using the same channel.
- ' Unfortunately this will have to wait for a proper fix.
- '
- Procedure SAM[VO1CE$,S4MPLE,FREQUENCY,L00P]
- '
- ' Parameters as the normal sam play command.
- ' The voice bitmap has to be a string because I can't get btst to work.
- ' L00P=0 - not looped
- ' L00P=-1 - looped
- '
- '---------------------------------------------------------------------
- '
- ' Assumes that samples are in bank 5.
- '
- STRT=Start(5)+Leek(Start(5)+2+4*(S4MPLE-1))+14
- LGTH=Leek(Start(5)+Leek(Start(5)+2+4*(S4MPLE-1))+10)
- '
- ' This makes sure that the first word of the sample is zero. The sample
- ' is stopped from playing by looping just the first word. It will squeal
- ' horribly if it is not zero.
- '
- Doke STRT,0
- '
- ' This bit sets a silent sample going.
- '
- Sam Raw Val(VO1CE$),Start(4),257,FREQUENCY
- '
- 'I then hijack the audio system for my own purposes
- '
- If Mid$(VO1CE$,5,1)="1" : Loke $DFF0A0,STRT : Doke $DFF0A4,LGTH/2 : End If
- If Mid$(VO1CE$,4,1)="1" : Loke $DFF0B0,STRT : Doke $DFF0B4,LGTH/2 : End If
- If Mid$(VO1CE$,3,1)="1" : Loke $DFF0C0,STRT : Doke $DFF0C4,LGTH/2 : End If
- If Mid$(VO1CE$,2,1)="1" : Loke $DFF0D0,STRT : Doke $DFF0D4,LGTH/2 : End If
- '
- 'Stop the sample from looping.
- '
- If Not L00P
- Wait(100*257)/FREQUENCY
- If Mid$(VO1CE$,5,1)="1" : Doke $DFF0A4,1 : End If
- If Mid$(VO1CE$,4,1)="1" : Doke $DFF0B4,1 : End If
- If Mid$(VO1CE$,3,1)="1" : Doke $DFF0C4,1 : End If
- If Mid$(VO1CE$,2,1)="1" : Doke $DFF0D4,1 : End If
- End If
- End Proc